﻿Imports System.Text
Imports ValorYReferencia
<TestClass()>
Public Class TemperaturaTest

    Private testContextInstance As TestContext

    '''<summary>
    '''Gets or sets the test context which provides
    '''information about and functionality for the current test run.
    '''</summary>
    Public Property TestContext() As TestContext
        Get
            Return testContextInstance
        End Get
        Set(ByVal value As TestContext)
            testContextInstance = Value
        End Set
    End Property

#Region "Additional test attributes"
    '
    ' You can use the following additional attributes as you write your tests:
    '
    ' Use ClassInitialize to run code before running the first test in the class
    ' <ClassInitialize()> Public Shared Sub MyClassInitialize(ByVal testContext As TestContext)
    ' End Sub
    '
    ' Use ClassCleanup to run code after all tests in a class have run
    ' <ClassCleanup()> Public Shared Sub MyClassCleanup()
    ' End Sub
    '
    ' Use TestInitialize to run code before running each test
    ' <TestInitialize()> Public Sub MyTestInitialize()
    ' End Sub
    '
    ' Use TestCleanup to run code after each test has run
    ' <TestCleanup()> Public Sub MyTestCleanup()
    ' End Sub
    '
#End Region

    <TestMethod()>
    Public Sub SetCelsiusAndCheckFahrenheitAndKelvin()
        Dim temp As New MedicionDeTemperatura()
        temp.Celsius = 0.01
        Assert.AreEqual(temp.Fahrenheit, 32.018, 0.0001)
        Assert.AreEqual(temp.Kelvin, 273.16, 0.0001)
    End Sub

    <TestMethod()>
    Public Sub SetFahrenheitAndCheckCelsiusAndKelvin()
        Dim temp As New MedicionDeTemperatura()
        temp.Fahrenheit = 32.018
        Assert.AreEqual(temp.Celsius, 0.01, 0.0001)
        Assert.AreEqual(temp.Kelvin, 273.16, 0.0001)
    End Sub

    <TestMethod()>
    Public Sub SetKelvinAndCheckCelsiusAndFahrenheit()
        Dim temp As New MedicionDeTemperatura()
        temp.Kelvin = 273.16
        Assert.AreEqual(temp.Celsius, 0.01, 0.0001)
        Assert.AreEqual(temp.Fahrenheit, 32.018, 0.0001)
    End Sub

    <TestMethod()>
    Public Sub SumarMediciones()
        Dim temp1 As New MedicionDeTemperatura()
        Dim temp2 As New MedicionDeTemperatura()
        temp1.Celsius = 100
        temp2.Celsius = 150
        Dim resultado As MedicionDeTemperatura = temp1 + temp2
        Assert.AreEqual(resultado.Celsius, temp1.Celsius + temp2.Celsius)
        Assert.AreEqual(resultado.Celsius, CType(250, Double)) ' o 250
    End Sub

    <TestMethod()>
    Public Sub RestarMediciones()
        Dim temp1 As New MedicionDeTemperatura()
        Dim temp2 As New MedicionDeTemperatura()
        temp1.Celsius = 100
        temp2.Celsius = 150
        Dim resultado As MedicionDeTemperatura = temp1 - temp2
        Assert.AreEqual(resultado.Celsius, temp1.Celsius - temp2.Celsius)
        Assert.AreEqual(resultado.Celsius, CType(-50, Double)) ' o -50
    End Sub

End Class
